selection sort javascript implementation